﻿
using SHKF.B2C.Model.Entity.Center;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SHKF.B2C.BLL.Center
{
    public class ProductInfoMapBLL : CenterBLL
    {

        public ProductInfoMapBLL(SqlSugarClient db) : base(db)
        {

        }


        /// <summary>
        /// 获取第三方产品Code
        /// </summary>
        /// <param name="ShopSN"></param>
        /// <param name="Upc"></param>
        /// <param name="Platform"></param>
        /// <returns></returns>
        public string QueryMedicineCode(long ShopSN, string Upc, string Platform)
        {
            string app_medicine_code = this.db
                 .Queryable<ProductInfoMapEntity>()
                 .InnerJoin<ProductInfoEntity>((ww, p) => ww.FKSN == p.SN)
                 .Where((ww, p) => p.ShopSN == ShopSN && ww.Upc == Upc && ww.Platform == Platform)
                 .Select(ww => ww.app_medicine_code)
                 .First();

            return app_medicine_code;
        }

        //public long GetProductSN(long app_medicine_id, string Platform)
        //{
        //   long ProductSN = base.db
        //       .Queryable<ProductInfoMapEntity>()
        //       .Where(oo=>oo.app_medicine_id == app_medicine_id && oo.Platform == Platform)
        //       .Select(a => a.ProductSN)
        //       .First();

        //    return ProductSN;
        //}

        //public long GetProductSN(string Item_No, string Platform)
        //{
        //    //先产品里找，如果没有在从 映射表里找，如果都没有。那说明没维护erp产品与第三方产品的关系

        //    long ProductSN = base.db
        //    .Queryable<ProductInfoMapEntity>()
        //    .Where(oo => oo.ItemNo == Item_No && oo.Platform == Platform)
        //    .Select(a => a.ProductSN)
        //    .First();
        //    return ProductSN;


        //}
    }
}
